home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / textureEditorIsolateSelect.m < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.1 KB  |  91 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //textureEditorIsolateSelect.mel
  18. //
  19. //must be in view faces of selected images mode to see effects
  20. //
  21. // $mode =
  22. //            0: remove all visible for selected object
  23. //            1: add selected to visible set
  24. //            2: remove selected from visible set
  25.  
  26. global proc textureEditorIsolateSelect(int $mode){
  27.     
  28.     // determine if textureEditorIsolateSelectSet exists
  29.     string $setExists[] = `ls textureEditorIsolateSelectSet`;
  30.     if (size($setExists) == 0)
  31.         sets -name "textureEditorIsolateSelectSet"
  32.             -facets true;
  33.     
  34.     // Begin changing the set
  35.     string $objects[] = `ls -sl`;
  36.     for ($object in $objects){
  37.         
  38.         //convert selection to faces
  39.         string $faces[] = `polyListComponentConversion 
  40.             -ff -fv -fe -fuv -fvf -tf $object`;
  41.         //if there are no faces then stop here and inform the user
  42.         if (size($faces) == 0){
  43.             error "Texture Editor Isolate Select only works with polygonal meshes.";
  44.         }
  45.         
  46.         switch( $mode ){
  47.         case 0:
  48.             string $shape[] = `listRelatives -parent -shapes $faces[0]`;
  49.             clear $faces;
  50.             $faces = `polyListComponentConversion -fv -fe -fuv -fvf -tf $shape[0]`;
  51.             sets -edit 
  52.                 -remove textureEditorIsolateSelectSet $faces;
  53.             // this is the end for this case so return
  54.             return;
  55.             break;
  56.             
  57.         case 1:
  58.             sets -edit 
  59.                 -addElement textureEditorIsolateSelectSet $faces;
  60.             break;
  61.             
  62.         case 2:
  63.             sets -edit 
  64.                 -remove textureEditorIsolateSelectSet $faces;
  65.             break;
  66.         }
  67.         
  68.         string $parent[] = `listRelatives -parent $object`;
  69.         
  70.         // Find out the groupId nodes connected to the mesh
  71.         string $meshGroupIdNode[] = `listConnections -type groupId
  72.             $parent[0]`;
  73.         string $setGroupIdNode[] = `listConnections -type groupId
  74.             textureEditorIsolateSelectSet`;
  75.         
  76.         // create an intersector to find the proper groupId
  77.         string $groupIdIntersector = `stringArrayIntersector`;
  78.         stringArrayIntersector -edit -intersect $meshGroupIdNode $groupIdIntersector;
  79.         stringArrayIntersector -edit -intersect $setGroupIdNode $groupIdIntersector;
  80.         string $groupIdNode[] = `stringArrayIntersector -query $groupIdIntersector`;
  81.         
  82.         // Get the magic number from that node
  83.         int $groupId = `getAttr ($groupIdNode[0] +".groupId")`;
  84.  
  85.         // Set that magic number to the meshShape
  86.         setAttr ($parent[0] + ".displayFacesWithGroupId") $groupId;
  87.                 
  88.     }
  89. }
  90.  
  91.